package cn.edu.lingnan.servlet.position;

import cn.edu.lingnan.pojo.Club;
import cn.edu.lingnan.pojo.Position;
import cn.edu.lingnan.service.ClubService;
import cn.edu.lingnan.service.ClubServiceMysqlImpl;
import cn.edu.lingnan.service.PositionService;
import cn.edu.lingnan.service.PositionServiceMysqlImpl;
import jakarta.servlet.ServletException;
import jakarta.servlet.annotation.WebServlet;
import jakarta.servlet.http.HttpServlet;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;

import java.io.IOException;

@WebServlet("/admin/position/updatePost")
public class UpdatePositionServlet extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        String sid=req.getParameter("sid");
        String cid=req.getParameter("cid");
        String ps=req.getParameter("ps");
        Position post=new Position(sid,cid,ps);
        System.out.println("要修改的职位信息："+post);
        PositionService service=new PositionServiceMysqlImpl();
        boolean flag=service.updatePsBySidAndCid(post);
        if(flag){
            System.out.println("修改成功");
        }else{
            System.out.println("修改失败");
        }
        resp.sendRedirect("/position/queryAllPost");
    }

    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        doGet(req,resp);
    }
}
